<?php 
	
	
	$toid = POST("id");
	$content = POST("content");
	$title = EdpSubStr( POST("title"), 1, 50 );
	
	if( IsParaOK() == false )
	{
		echo_validation_message();
		exit();
	}
	
	$uid = GetLoginUserID();
	if($uid===false)
	{
		echo "非法的站内信操作";
		edp_exit();
	}
	else
	{
		$userDAO = GetUserDAO();
		
		$idNicks = $userDAO->ValidateIDs( edp_db_input($toid) );
		
		if( count($idNicks) > 0)
		{
			$receivers_id = array();
			
			foreach( $idNicks as $key => $value )
				$receivers_id[] = $value['id'];
			
			$letterDAO = GetLetterDAO();
			$letterDAO->SendLetter( $receivers_id, $uid, GetLoginUserName(), 
				edp_db_input($title), edp_db_input($content));
		}
		
		echo 0;
		edp_exit();
	}
	
?>